<?php
namespace Admin\Controller;
use Think\Controller;

class AdminruleController extends Controller {
    public function index(){
        
       /* $rules = M('auth_rule')->select();*/

        $sql = "select t1.*,t2.cname from auth_rule t1 left join auth_category t2 on t1.cid=t2.cid order by id";

        $rules = M()->query($sql);

        $this->assign('rules',$rules);

        $cates = M('auth_category')->select();

        $this->assign('cates',$cates);

        $this->display();
    }

    public function add(){
    	$data = I('post.');
    	/*var_dump($data);exit;*/
    	$result = M('auth_rule')->add($data);

    	if($result){
    		$this->ajaxReturn(['error'=>0,'info'=>'添加成功']);
    	}else{
    		$this->ajaxReturn(['error'=>1,'info'=>'添加失败']);
    	}
    }
}

?>